package com.ea.common.exception;

import com.ea.common.enums.OperationResultCode;

import java.util.HashMap;
import java.util.Map;

/**
 * @author NAME-L
 * @Description TODO
 * @className ServiceException
 * @date 2022-12-07 23:25:24
 */
public class ServiceException extends RuntimeException {

    /**
     * 错误码
     */
    protected String errorCode;

    /**
     * 错误信息
     */
    protected String errorMsg;

    /**
     * 返回数据
     */
    private Map<String, Object> errorData;


    public ServiceException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.errorData = null;
    }




    public ServiceException(String errorCode, String errorMsg , Map<String, Object> errorData) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
        this.errorData = errorData;
    }

    public ServiceException(OperationResultCode resultCode) {
        super(resultCode.getMsg());
        this.errorCode = resultCode.getCode() ;
        this.errorMsg = resultCode.getMsg();
        this.errorData = null;
    }


    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    public Map<String, Object> getErrorData() {
        return errorData;
    }

    public void setErrorData(Map<String, Object> errorData) {
        this.errorData = errorData;
    }
}
